package com.senseauto.mediacodecdemo;

public class CarImageUtil {

    public static byte[] mirrorYuv(byte[]data, int width, int height){
        byte[]mirrorData= new byte[data.length];
        int i=0;
        for(int y = 0;y<height;y++){ //第几行的数据
            for(int x = width-1; x >=0; x--){ //当前这一行的x坐标  从后往前复制，解决镜像问题
                mirrorData[i] = data[y*width + x];
                i++;
            }
        }
        /*for(int y=1;y<=height/2;y++){ //第几行uv数据
            for(int x = width/2;x>=0;x= x-2){
                mirrorData[i] = data[width*height+ y*width + x-1];
                i++;
                mirrorData[i] = data[width*height+ y*width + x];
            }
        }*/
        for (int y = 0; y < height/2; y++) {
            for (int x = width-1; x >=0; x= x-2) {
                mirrorData[i] = data[(width * height) + (y * width) + x - 1];
                i++;
                mirrorData[i] = data[(width * height) + (y * width) + x];
                i++;
            }
        }
        return mirrorData;
    }
}
